package com.zzw.config;

import com.zzw.interceptor.InternalHandlerInterceptor;
import jakarta.annotation.Resource;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @author Administrator
 */
public class CommonsServerWebMvcConfigurer implements WebMvcConfigurer {

    @Resource
    List<InternalHandlerInterceptor> internalHandlerInterceptors;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        for (InternalHandlerInterceptor internalHandlerInterceptor : internalHandlerInterceptors) {
            registry.addInterceptor(internalHandlerInterceptor)
                    .addPathPatterns(internalHandlerInterceptor.getInterceptorCommonsProperties().getPathPatterns())
                    .excludePathPatterns(internalHandlerInterceptor.getInterceptorCommonsProperties().getExcludePathPatterns());
        }
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
